package window;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;




public class Window extends JFrame implements ActionListener, MouseListener {
	/**
	 * Data members
	 * - the serialVersionUID is needed to get rid of a compiler warning
	 * - 
	 */
	private static final long serialVersionUID = 1L;
	private static final String TITLE_STRING = "Inheritance and Composition";

	private JLabel left;
	private ImageIcon alternateLeft;
	private LabelCard middle;
	private CardLabel right;
	
	private static final int[] xpos = { 50, 150, 250 };
	private static final int[] ypos = { 50,  50,  50 };

	public Window(){
		super( TITLE_STRING );
		setBounds(100, 100, 400, 300);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLayout( null );

		// Set up left card
		left = new JLabel( new ImageIcon("src/cards/CardImages/01a.jpg") );
		alternateLeft = new ImageIcon("src/cards/CardImages/02a.jpg");
		left.setBounds(xpos[0], ypos[0], left.getIcon().getIconWidth(), left.getIcon().getIconHeight() );
		left.addMouseListener( this );
		left.setName("Left");
		add( left );
		
		// Set up middle card
		middle = new LabelCard( new ImageIcon("src/cards/CardImages/01b.jpg"), new ImageIcon("src/cards/CardImages/02b.jpg") );
		middle.setBounds(xpos[1], ypos[1], middle.getIcon().getIconWidth(), middle.getIcon().getIconHeight() );
		middle.addMouseListener( this );
		middle.setName("Middle");
		add( middle );

		
		// Set up right card
		right = new CardLabel( new ImageIcon("src/cards/CardImages/01c.jpg"), new ImageIcon("src/cards/CardImages/02c.jpg"));
//		right.setBounds(xpos[2], ypos[2], right.getIcon().getIconWidth(), right.getIcon().getIconHeight() );
//		right.addMouseListener( this );
//		right.setName("Right");
//		add( right );


		setVisible( true );
	}

	public void mouseClicked(MouseEvent arg0) {
		JLabel source = (JLabel) arg0.getSource();
		System.out.println( "  " + source.getName() + ": mouse clicked" );
	}

	public void mouseEntered(MouseEvent arg0) {
		JLabel source = (JLabel) arg0.getSource();
		System.out.println( "  " + source.getName() + ": mouse entered" );
	}

	public void mouseExited(MouseEvent arg0) {
		JLabel source = (JLabel) arg0.getSource();
		System.out.println( "  " + source.getName() + ": mouse exited" );
	}

	public void mousePressed(MouseEvent arg0) {
		JLabel source = (JLabel) arg0.getSource();
		System.out.println( "  " + source.getName() + ": mouse pressed" );
	}

	public void mouseReleased(MouseEvent arg0) {
		JLabel source = (JLabel) arg0.getSource();
		System.out.println( "  " + source.getName() + ": mouse released" );		
	}

	public void actionPerformed(ActionEvent arg0) {
		JLabel source = (JLabel) arg0.getSource();
		System.out.println( "  " + source.getName() + ": action." );
	}
	
	/**
	 * main - the program starts here.
	 * 
	 * @param args
	 */
	public static void main(String[] a){
		new Window();
	}
}
